<?php

/**
 * content json
 * [
 *    'goodsId' => [
 *
 *      'goodsId'=> goodsid,
 *      'num' => num,
 *      'goodsNo' => goodsNo,
 *      'update_time' => update_time,
 *    ],
 * ]
 */

class user_cartModel extends Model {

	public function getUserGoods($userCartInfo) {
		if (!isset($userCartInfo['content']) || !$userCartInfo['content']) {
			return [];
		}
		return json_decode($userCartInfo['content'], true);
	}

	public function buildCart($cartContentArray) {
		$cartData = [];
		if (!$cartContentArray) {
			return [];
		}
		foreach ($cartContentArray as $cartInfo) {
			$cartData[$cartInfo['specification_id']] = $cartInfo;
		}
		return $cartData;
	}
}